package java_generics.generic_methods;

public class PrintArray {

	// Following example illustrate how we can print array
	// of different type using a single Generic method
	public static <E> void printArray(E[] inputArray) {
		// Display array elements
		for (E element : inputArray) {
			System.out.printf("%s ", element);
		}
		System.out.println();
	}

	public static void main(String args[]) {
		// Create arrays of Integer, Double and Character
		Integer[] intArray = { 1, 2, 3, 4, 5 };
		printArray(intArray); // pass an Integer array

		Double[] doubleArray = { 1.0, 1.1, 1.2, 1.3, 1.4 };
		printArray(doubleArray); // pass a Double array

		Character[] charArray = {'G','E','N','E','R','I','C','S' };
		printArray(charArray); // pass a Character array
	}
}
